<template>
	<!-- 农业银行 -->
	<view v-if="list">
		<view class="statusBar"></view>
		<view class="daohang">
			<view class="daohangicon" @tap="backBtn">❮</view>
			<view>明细</view>
			<view class="daohangicon" style="font-size: 3.6vw;text-align: left;color: #888888;">导出</view>
		</view>
		<view class="demo1">
			asdasd
		</view>
		<view class="kaTit">
			<view>
				<image src="../../static/bank-icon5.png" mode="widthFix"></image>{{list.balance.bankCode.replace(/^(\w{4})\w{11}(.*)$/, '$1 **** $2')}}<image style="width: 2.6vw;margin-left: 3.6vw;" src="../../static/bank-icon6.png" mode="widthFix"></image>
			</view>
			<view>人民币 | 本币<image style="width: 2.6vw;margin-left: 3vw;" src="../../static/bank-icon6.png" mode="widthFix"></image></view>
		</view>
		<view class="myDate">
			<view>近一周</view>
			<view style="color: #FFFFFF;background: #f0aa38;">近一月</view>
			<view>近三月</view>
			<view style="display: flex;flex-direction: row;align-items: center;">筛选<image style="width: 2.6vw;margin-left: 3.6vw;" src="../../static/bank-icon6.png" mode="widthFix"></image></view>
		</view>
			<scroll-view scroll-y="true" style="height: 132vw;">
				<view class="main" v-for="(item,index) in list.list" :key="index" @tap="delBtn" :data-id="item.id">
					<view>
						<view style="font-size: 4.4vw;color: #333333;display: flex;flex-direction: row;align-items: center;">{{item.payTypeStr}}<image style="width: 3vw;margin-left: 0.8vw;" v-if="item.payType==3" src="../../static/nhicon1.png" mode="widthFix"></image></view>
						<view style="font-size: 3.8vw;color: #999999;">{{item.createTime}}</view>
					</view>
					<view>
						<view style="font-size: 4.4vw;" :class="item.payType==0?'mycolor':''">{{item.payType==0?'+':'-'}}{{item.showAmount}}</view>
						<view style="font-size: 3.8vw;color: #999999;">余额：{{item.amount2}}</view>
					</view>
					<view style="font-size: 6vw;color: #999999;">❯</view>
				</view>
			</scroll-view>
	</view>
</template>

<script>
	const http = require('../../utils/http.js');
	export default {
		data() {
			return {
				id:null,
				list:'',
				year:null,
				month:null,
				kaNum:null
			}
		},
		onLoad(options) {
			this.id=options.id
		},
		onShow() {
			var now = new Date();
			this.year = now.getFullYear(); //年
			if((now.getMonth() + 1) < 10){ //月
				this.month = '0'+(now.getMonth() + 1)
			}else{
				this.month = now.getMonth() + 1;
			}
			uni.showLoading({
			    title: '加载中'
			});
			http.get('/api/balance/getBalanceDetail',{balanceId:this.id}).then(res => {
				//console.log(res.result.balance.bankCode)
				//console.log(res.result.balance.bankCode.replace(/^(\w{4})\w{10}(.*)$/, '$1***$2'))
				if (res.code == 200 && res.result) {
					this.list=res.result
					this.kaNum=res.result.balance.bankCode.replace(/^(\w{4})\w{11}(.*)$/, '$1****$2')
				}
				uni.hideLoading();
			})
		},
		methods: {
			backBtn:function(){
				uni.navigateBack({
					delta: 1
				})
			},
			delBtn:function(e){
				var that=this
				uni.showModal({
				    title: '删除',
				    content: '确定删除该数据吗？',
				    success: function (res) {
				        if (res.confirm) {
				            //console.log(e.currentTarget.dataset.id);
							uni.showLoading({
							    title: '加载中'
							});
							http.get('/api/balance/delBalanceDetail',{balanceDetailId:e.currentTarget.dataset.id}).then(res => {
								uni.showToast({
								  title: res.message,
								  icon: 'none'
								});
								if(res.code==200){
									http.get('/api/balance/getBalanceDetail',{balanceId:that.id}).then(res1 => {
										if (res1.code == 200 && res1.result) {
											that.list=res1.result
										}
									})
								}
								uni.hideLoading();
							})
				        } else if (res.cancel) {
				            console.log('用户点击取消');
				        }
				    }
				});
			}
		}
	}
</script>

<style>
	page{
		color: #333333;
	}
	.statusBar{
		height: 6vw;
		background: #FFFFFF;
	}
	.mycolor{
		color: #f4c364;
	}
	.daohang{
		display: flex;
		align-items: center;
		justify-content: space-between;
		color: #333333;
		background: #FFFFFF;
		padding: 2.8vw 0;
	}
	.daohang .daohangicon{
		font-size: 5vw;
		width: 12%;
		text-align: center;
	}
	.daohang view:nth-child(2){
		text-align: center;
		font-weight: bold;
		font-family: sans-serif;
	}
	.kaTit{
		padding: 2.6vw 4vw;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
	}
	.kaTit>view{
		display: flex;
		flex-direction: row;
		align-items: center;
	}
	.kaTit image{
		width: 5.5vw;
		margin-right: 2vw;
	}
	.myDate{
		background: #F2F2F2;
		padding: 4.6vw 5vw;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
	}
	.myDate>view{
		background: #FFFFFF;
		padding: 1.8vw 5vw;
		border-radius: 500vw;
		font-size: 3.4vw;
		color: #333333;
	}
	.main{
		margin: 0 0 0 5vw;
		padding: 2.6vw 0 2.6vw 0;
		display: flex;
		justify-content: space-between;
		align-items: center;
		border-bottom: 1px solid #F2F2F2;
	}
	.main>view:nth-child(1)>view:nth-child(1),.main>view:nth-child(2)>view:nth-child(1){
		margin-bottom: 2vw;
	}
	.main>view:nth-child(2){
		flex: 1;
		text-align: right;
	}
	.main>view:nth-child(3){
		padding: 0 5vw;
	}
</style>
